home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gui / muibuilderv11.lha / muibuilder / mb / c / Characters.c < prev    next >
C/C++ Source or Header  |  1994-04-02  |  6KB  |  231 lines

  1. #include <libraries/mui.h>
  2. #include <proto/muimaster.h>
  3. #include <clib/exec_protos.h>
  4. #include <clib/alib_protos.h>
  5. #include <exec/memory.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8.  
  9. #ifndef MAKE_ID
  10. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  11. #endif
  12.  
  13. #ifdef _DCC
  14. #define __inline
  15. #endif
  16.  
  17. struct Library *MUIMasterBase, *LocaleBase;
  18.  
  19. /*************************/
  20. /*    Fail Function      */
  21. /*************************/
  22.  
  23. static VOID fail(APTR app,char *str)
  24. {
  25.         if (app)
  26.                 MUI_DisposeObject(app);
  27.  
  28. #ifndef _DCC
  29.         if (MUIMasterBase)
  30.                 CloseLibrary(MUIMasterBase);
  31. #endif
  32.     if (str)
  33.         {
  34.                 puts(str);
  35.                 exit(20);
  36.         }
  37.         exit(0);
  38. }
  39.  
  40. /*************************/
  41. /*    Init Function      */
  42. /*************************/
  43.  
  44. static VOID init(VOID)
  45. {
  46. #ifdef _DCC
  47.         onbreak(brkfunc);
  48. #endif
  49.  
  50. #ifndef _DCC
  51.         if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  52.                 fail(NULL,"Failed to open "MUIMASTER_NAME".");
  53. #endif
  54. }
  55.  
  56. /*************************/
  57. /* InitLocale Function   */
  58. /*************************/
  59.  
  60. static VOID initlocale(VOID)
  61. {
  62. #ifndef _DCC
  63.         LocaleBase = OpenLibrary("Locale.library",38L);
  64. #endif
  65.     /* YOU MUST write this function !!! */
  66.         /* OpenCatalog(NULL,NULL); */
  67. }
  68.  
  69. /****************************************************************/
  70. /*      ExTended KeyButton ( or Eric Totel KeyButton :-) )      */
  71. /*      to use with localization features                       */
  72. /****************************************************************/
  73.  
  74. static APTR __inline ETKeyButton(char *text)
  75. {
  76.         return (KeyButton(&text[3], text[1]));
  77. }
  78.  
  79.  
  80.  
  81. int main( int argc, char *argv[] )
  82. {
  83.     ULONG    signal;
  84.     BOOL    running = TRUE;
  85.     APTR    App, WI_Characters, STR_name, CY_sex, RA_Race, RA_Class, CH_cloak, CH_shield;
  86.     APTR    CH_gloves, CH_helmet, SL_experience, SL_strength, SL_dexterity, SL_condition;
  87.     APTR    SL_intelligence;
  88.     char    *STR_CY_sex[3], *STR_GR_Register[5], *STR_RA_Race[6], *STR_RA_Class[7];
  89.  
  90.     STR_CY_sex [0] = "female";
  91.     STR_CY_sex [1] = "male";
  92.     STR_CY_sex [2] = NULL;
  93.     STR_GR_Register [0] = "Race";
  94.     STR_GR_Register [1] = "Class";
  95.     STR_GR_Register [2] = "Armor";
  96.     STR_GR_Register [3] = "Level";
  97.     STR_GR_Register [4] = NULL;
  98.     STR_RA_Race [0] = "Human";
  99.     STR_RA_Race [1] = "Elf";
  100.     STR_RA_Race [2] = "Dwarf";
  101.     STR_RA_Race [3] = "Hobbit";
  102.     STR_RA_Race [4] = "Gnome";
  103.     STR_RA_Race [5] = NULL;
  104.     STR_RA_Class [0] = "Warrior";
  105.     STR_RA_Class [1] = "Rogue";
  106.     STR_RA_Class [2] = "Bard";
  107.     STR_RA_Class [3] = "Monk";
  108.     STR_RA_Class [4] = "Magician";
  109.     STR_RA_Class [5] = "Archmage";
  110.     STR_RA_Class [6] = NULL;
  111.  
  112.     init();
  113.  
  114.  
  115.     App = ApplicationObject,
  116.         MUIA_Application_Author, "Stefan Stuntz",
  117.         MUIA_Application_Base, "CHARACTER",
  118.         MUIA_Application_Title, "Characters",
  119.         MUIA_Application_Version, "$VER: Characters 1.1 (xx.xx.xx)",
  120.         MUIA_Application_Copyright, "Stefan Stuntz",
  121.         MUIA_Application_Description, "Just an example !!",
  122.         MUIA_HelpFile, "character.guide",
  123.         SubWindow, WI_Characters = WindowObject,
  124.             MUIA_Window_Title, "Characters",
  125.             MUIA_HelpNode, "WI_Characters",
  126.             MUIA_Window_ID, MAKE_ID( '0','W','I','N' ),
  127.             WindowContents, GroupObject,
  128.                 Child, GroupObject,
  129.                     MUIA_HelpNode, "GR_Global",
  130.                     MUIA_Group_Columns, 2,
  131.                     Child, Label( "Name" ),
  132.                     Child, STR_name = StringObject,
  133.                         StringFrame,
  134.                         MUIA_HelpNode, "STR_name",
  135.                         MUIA_String_MaxLen, 80,
  136.                         MUIA_String_Format, 0,
  137.                     End,
  138.                     Child, Label( "Sex" ),
  139.                     Child, CY_sex = CycleObject,
  140.                         MUIA_HelpNode, "CY_sex",
  141.                         MUIA_Cycle_Entries, STR_CY_sex,
  142.                     End,
  143.                 End,
  144.                 Child, RegisterGroup( STR_GR_Register ),
  145.                     Child, RA_Race = RadioObject,
  146.                         GroupFrameT( "Race" ),
  147.                         MUIA_Radio_Entries, STR_RA_Race,
  148.                     End,
  149.                     Child, RA_Class = RadioObject,
  150.                         GroupFrameT( "Class" ),
  151.                         MUIA_Radio_Entries, STR_RA_Class,
  152.                     End,
  153.                     Child, GroupObject,
  154.                         GroupFrameT( "Armor" ),
  155.                         MUIA_Group_Columns, 2,
  156.                         Child, Label( "Cloak" ),
  157.                         Child, CH_cloak = CheckMark( 0 ),
  158.                         Child, Label( "Shield" ),
  159.                         Child, CH_shield = CheckMark( 0 ),
  160.                         Child, Label( "Gloves" ),
  161.                         Child, CH_gloves = CheckMark( 0 ),
  162.                         Child, Label( "Helmet" ),
  163.                         Child, CH_helmet = CheckMark( 0 ),
  164.                     End,
  165.                     Child, GroupObject,
  166.                         GroupFrameT( "Level" ),
  167.                         MUIA_Group_Columns, 2,
  168.                         Child, Label( "Experience" ),
  169.                         Child, SL_experience = SliderObject,
  170.                             MUIA_Slider_Min, 0,
  171.                             MUIA_Slider_Max, 100,
  172.                             MUIA_Slider_Quiet, 0,
  173.                             MUIA_Slider_Level, 3,
  174.                             MUIA_Slider_Reverse, 0,
  175.                         End,
  176.                         Child, Label( "Strength" ),
  177.                         Child, SL_strength = SliderObject,
  178.                             MUIA_Slider_Min, 0,
  179.                             MUIA_Slider_Max, 100,
  180.                             MUIA_Slider_Quiet, 0,
  181.                             MUIA_Slider_Level, 10,
  182.                             MUIA_Slider_Reverse, 0,
  183.                         End,
  184.                         Child, Label( "Dexterity" ),
  185.                         Child, SL_dexterity = SliderObject,
  186.                             MUIA_Slider_Min, 0,
  187.                             MUIA_Slider_Max, 100,
  188.                             MUIA_Slider_Quiet, 0,
  189.                             MUIA_Slider_Level, 24,
  190.                             MUIA_Slider_Reverse, 0,
  191.                         End,
  192.                         Child, Label( "Condition" ),
  193.                         Child, SL_condition = SliderObject,
  194.                             MUIA_Slider_Min, 0,
  195.                             MUIA_Slider_Max, 100,
  196.                             MUIA_Slider_Quiet, 0,
  197.                             MUIA_Slider_Level, 39,
  198.                             MUIA_Slider_Reverse, 0,
  199.                         End,
  200.                         Child, Label( "Intelligence" ),
  201.                         Child, SL_intelligence = SliderObject,
  202.                             MUIA_Slider_Min, 0,
  203.                             MUIA_Slider_Max, 100,
  204.                             MUIA_Slider_Quiet, 0,
  205.                             MUIA_Slider_Level, 74,
  206.                             MUIA_Slider_Reverse, 0,
  207.                         End,
  208.                     End,
  209.                 End,
  210.             End,
  211.         End,
  212.     End;
  213.  
  214.     /*  Notification */
  215.     DoMethod(WI_Characters, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  216.  
  217.     set( WI_Characters, MUIA_Window_Open, TRUE );
  218.  
  219.     while (running)
  220.     {
  221.         switch (DoMethod(App,MUIM_Application_Input,&signal))
  222.         {
  223.         case MUIV_Application_ReturnID_Quit:
  224.         running = FALSE;
  225.         break;
  226.         }
  227.     if (signal) Wait(signal);
  228.     }
  229.     fail(App, NULL);
  230. }
  231.